Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHON-1309 cqlengine: Remove deepcopy on UserType deserialization #1192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

k0machi
Copy link

@k0machi k0machi commented Dec 4, 2023

This change makes it so newly instanced UserType during deserialization isn't immediately copied by deepcopy, which could cause huge slowdown if that UserType contains a lot of data or nested UserTypes, in which case the deepcopy calls would cascade as each to_python call would eventually clone parts of source object. As there isn't a lot of information on why this deepcopy is here in the first place this change could potentially break something. Running integration tests against this commit does not produce regressions, so this call looks safe to remove, but I'm leaving this warning here for the future reference.

Issue: scylladb#152
Issue (upstream): PYTHON-1309

Here are flamegraphs for an application that uses cqlengine and encounters this issue:

  • Before
    profile-1

  • After
    profile2

The request time goes from 10 seconds in this case down to 750ms, for reference the table is configured with a list of UserTypes that have a list of another UserType inside them.

This change makes it so newly instanced UserType during deserialization
isn't immediately copied by deepcopy, which could cause huge slowdown if
that UserType contains a lot of data or nested UserTypes, in which case the
deepcopy calls would cascade as each to_python call would eventually clone
parts of source object. As there isn't a lot of information on why this
deepcopy is here in the first place this change could potentially break
something. Running integration tests against this commit does not produce
regressions, so this call looks safe to remove, but I'm leaving this
warning here for the future reference.

Issue: scylladb#152
@fruch
Copy link

fruch commented Dec 13, 2023

@absurdfarce you think someone would be able to take a look at this one ? (there was no response on the related issue: https://datastax-oss.atlassian.net/browse/PYTHON-1309)

@k0machi k0machi changed the title cqlengine: Remove deepcopy on UserType deserialization PYTHON-1309 cqlengine: Remove deepcopy on UserType deserialization Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants